<?php

namespace Modules\Buy\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class AuthRequest extends FormRequest
{
    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            //unique(验证user表中是否存在用户的名字)
//            'name' => 'required|min:3|max:10|unique:user,name',
            //email属性就是验证是否符合email规则
            'email' => 'required',
            //confirmed就是验证密码和确认密码保持一致
            'password' => 'required|min:8|max:16|confirmed',
            'password_confirmation' =>'required|between:8,16'
        ];
    }


    public function messages()
    {
        return array (
            'email.required'=>'邮箱不能为空',
            'password.required'=>'密码不能为空',
            'password.confirmed'=>'两次密码不一致',
            'password_confirmation.required'=>'确认密码不能为空'
        );
    }

    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }
}
